Welcome Guest Search | Active Topics | Sign In | Register

slideMenu c# adding sub-menu in code behind Options
jojoRLevy
Posted: Friday, April 17, 2009 4:32:24 PM
Rank: Newbie
Groups: Member

Joined: 4/17/2009
Posts: 2
I am building a slider menu with two levels of submenu under the TopGroup. I need to build the menu in code behind (not using data binding) since the data comes from several unrelated dataSets. I found the code in the documentation about adding items to a menu.

menu.Items[1].Add(newItem)

It seems like the .Add and .Insert method only takes objects of type "MenuItem" as parameters (or strings to build MenuItems)

Is there a method I'm not seeing for adding submenus to an item?

Thanks
-Jordan L.
eo_support
Posted: Friday, April 17, 2009 4:41:04 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi,

There are four overloaded version for the Add method:

http://doc.essentialobjects.com/library/1/eo.web.menuitemcollection.add_overloads.aspx

The first one takes a MenuItem object, all other three take strings. You can click any one of them to find detailed information about each version, such as what each parameter is for.

Thanks
jojoRLevy
Posted: Friday, April 17, 2009 4:48:05 PM
Rank: Newbie
Groups: Member

Joined: 4/17/2009
Posts: 2
Thanks - I saw the overloads but thought they would all result in a new MenuITem not a new subMenu. I'll try them out and see which one is for adding a subMenu.

- J

PS: I figured it out. If anyone else needs to see sample code for adding menuItems or sub-Menus using c# in the code behind.

Code: C#
// create new menu item
		EO.Web.MenuItem itemTop = new EO.Web.MenuItem();
		itemTop.Text.Html = "My Menu itemTop";
		// add item to the top of my menu (SlideMenu1) defined on the ASPX page
		SlideMenu1.TopGroup.Items.Add(itemTop);

		EO.Web.MenuItem itemSub = new EO.Web.MenuItem();
		itemSub.Text.Html = "My Menu Sub Menu";
		//add item to what was just created
		itemTop.SubMenu.Items.Add(itemSub); 

		//create second item
		EO.Web.MenuItem itemSub2 = new EO.Web.MenuItem();
		itemSub2.Text.Html = "My Menu Sub Menu Item 2";
		itemTop.SubMenu.Items.Add(itemSub2);

		EO.Web.MenuItem itemThird = new EO.Web.MenuItem();
		itemThird.Text.Html = "My Menu item Third";
		//add item to the sub menu 1 that was just created
		itemSub.SubMenu.Items.Add(itemThird);




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.